<?php
  $arr= [
       ['id'=>1,'name'=>'sm','fid'=>1,'fname'=>2],
      ['id'=>1,'name'=>'sm','fid'=>1,'fname'=>3],
      ['id'=>1,'name'=>'sm','fid'=>1,'fname'=>4],
      ['id'=>1,'name'=>'sm','fid'=>1,'fname'=>5],
      ['id'=>2,'name'=>'ara','fid'=>1,'fname'=>6],
      ['id'=>2,'name'=>'ara','fid'=>1,'fname'=>7],
      ['id'=>2,'name'=>'ara','fid'=>1,'fname'=>8],
      ['id'=>2,'name'=>'ara','fid'=>1,'fname'=>9],

  ];
  $varr=[];

  foreach ($arr as $value){
       if(isset($varr[$value['id']])){
           $varr[$value['id']]['child'][]=['fid'=>$value['fid'],'fname'=>$value['fname']];
       }else{
           $varr[$value['id']]=['id'=>$value['id'],'name'=>$value['name']];
           $varr[$value['id']]['child'][]=['fid'=>$value['fid'],'fname'=>$value['fname']];
       }
  }

echo "<pre>";print_r($varr);echo "<pre>";